package leetcode.offer_two_special.tree;

import leetcode.tree.common.TreeNode;

/**
 * @author mazouri
 * @create 2021-09-12 22:43
 */
public class _54_convertBST {
    int sum = 0;
    public TreeNode convertBST(TreeNode root) {
        if (root !=null){
            convertBST(root.right);
            sum+= root.val;
            root.val  =sum;
            convertBST(root.left);
        }
        return root;
    }
}
